<% content_for :sidebar do %>
  <h1>Listing inspections</h1>
<% end %>

<table id="inspections" class="datatable table table-striped table-bordered">
  <caption><h3><%= "Inspections" %></h3></caption>
  <thead>
    <tr>
      <th>Item</th>
      <th>Inspection Date</th>
      <th>Inspection Status</th>
      <th>Comments</th>
      <th></th>
      <th></th>
    </tr>
  </thead>
  <tbody>
    <% @inspections.each do |inspection| %>
      <tr>
        <td><%= link_to inspection.item&.name, inspection.item %></td>
        <td><%= link_to format_datetime_value(inspection.inspection_date), inspection %></td>
        <td><%= inspection_status_label(inspection) %></td>
        <td><%= truncate(inspection.comments) %></td>
        <td><%= table_button_link 'Edit', edit_inspection_path(inspection) if can? :edit, inspection %></td>
        <td><%= table_button_link 'Destroy', inspection, method: :delete if can? :destroy, inspection %></td>
      </tr>
    <% end %>
  </tbody>
</table>
